Skip to content

Beginning touch support #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: arduino
Choose a base branch
from

Conversation

KurtE
Copy link

@KurtE KurtE commented Jun 5, 2025

Add a callback function for the touch device
within the fixups for the GIGA. This callback
simply remembers the last touch that happened and
sets a semaphore.

There is also a function added to retrieve this data.

Needed to add the callback function into the exports file.

EDIT: As I mentioned in
#92

This is maybe not a complete setup yet. Currently the zephyr touch device is configured for only one touch
Where it believe is supposed to support up to 5. Also with it only doing one touch, it does not support
gestures. I will integrate our WIP touch code into the Arduino_GIGATouch library such that it is all
available for us or others to fill this in.

@KurtE
Copy link
Author

KurtE commented Jun 5, 2025

Wondering, an alternative implementation for this would be instead of having a handler here, that
receives all of the messages and creates a simple record of X, y, ... Instead just have method which sets
the call back function. Which is set the callback we define here simply calls it...

void (*user_callback)(struct input_event *evt, void *user_data) = 0;
void touch_event_callback(struct input_event *evt, void *user_data)
{
    //printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
    if (user_callback) (*user_callback)(evt, user_data);
}
...

Or could do combination of both....

Thoughts?

@KurtE
Copy link
Author

KurtE commented Jun 6, 2025

Talking to self (and maybe others)

In certain ways, I think the idea of setting a callback function like I mentioned in the previous comment, might make sense,

but one thing (of many) I don't understand, is how to do that in a safe way. That is Suppose, I setup and run our example Touch Paint sketch, which registers it's callback. Then suppose I decide to run some simple sketch like blink. After Blink loads, my guess is that the callback pointer would be set to wherever it was in the previous sketch, and if the user touches the screen, we will
call off to potential garbage...

Or is there some method we call at sketch startup that can clear the callback(s)...

EDIT: One option, is maybe add the InitVariant for the GIGA, and set it to NULL at that point...

@KurtE KurtE force-pushed the giga_display_callback branch from 13960d6 to a046e8d Compare June 11, 2025 21:47
@KurtE KurtE force-pushed the giga_display_callback branch 5 times, most recently from 89d3fd5 to 7abe8c3 Compare June 18, 2025 12:33
KurtE added a commit to KurtE/zephyr that referenced this pull request Jun 22, 2025
Currently the config option:
CONFIG_INPUT_GT911_MAX_TOUCH_POINTS

is not defined for the Giga display shield and defaults
to 1.   The valid range is 1-5, I have done most of my
own testing using 3 with the ArduinoGiga-zephyr

I have a PR against the ArduinoCore-zephyr project
which allows me to define a callback in the Arduino
system:
arduino/ArduinoCore-zephyr#134
And a version of the Arduino touch library with some
support, the fork/branch
https://github.com/KurtE/Arduino_GigaDisplayTouch/tree/zephyr

And an example sketch that does touch paint.
arduino/ArduinoCore-zephyr#92 (comment)

Note: my version of the Arduino touch library has no support for gestures

Signed-off-by: Kurt Eckhardt <[email protected]>
KurtE added a commit to KurtE/zephyr that referenced this pull request Jun 22, 2025
Currently the config option:
CONFIG_INPUT_GT911_MAX_TOUCH_POINTS

is not defined for the Giga display shield and defaults
to 1.   The valid range is 1-5, I have done most of my
own testing using 3 with the ArduinoGiga-zephyr

I have a PR against the ArduinoCore-zephyr project
which allows me to define a callback in the Arduino
system:
arduino/ArduinoCore-zephyr#134

And a version of the Arduino touch library with some
support, the fork/branch
https://github.com/KurtE/Arduino_GigaDisplayTouch/tree/zephyr

And an example sketch that does touch paint.
arduino/ArduinoCore-zephyr#92 (comment)

Note: my version of the Arduino touch library has no support
for gestures

Signed-off-by: Kurt Eckhardt <[email protected]>
@KurtE KurtE force-pushed the giga_display_callback branch from 7abe8c3 to 135693d Compare June 24, 2025 18:32
@KurtE
Copy link
Author

KurtE commented Jun 24, 2025

@ALL - I cleaned up some of the code in this PR to cleanup which CONFIG_ the code is under for touch.

Instead of VIDEO (which is for camera) it uses CONFIG_INPUT_GT911_INTERRUPT

Warning these fixes also included fixes that allow the GC2145 camera to work on Portenta H7.

Let me know if there is anything you think that should be changed.

…er in fixups.

Added the ability to register a callback function to be called by the zephyr input
system.

This new code is only there if it is a GIGA and CONFIG_INPUT_GT911_INTERRUPT is defined.

This includes adding a callback function that is linked in to the zephyr build,  and export
a function to call to allow us to register our own.

Added an init variant to GIGA that if the touch interrupt is enabled, then it will clear out the old user defined
callback if any.

This version also added in the changes to fixups that allow a camera to work on Portenta H7.
Needed to have it do the same as GIGA to start the PWM if INPUT is configured in.

And updated the portentas remote_endpoint define to be using the same format as used in the giga overlay
Also changed to STM32_DMA_FIFO_1-4, like the GIGA currently has

Update arduino_portenta_h7_stm32h747xx_m7.overlay
@KurtE KurtE force-pushed the giga_display_callback branch from 135693d to 6e05523 Compare June 24, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant